package com.wangzh.data.arithmetic.recursion.queue;

import com.wangzh.data.TreeNode;

//二叉树
public class BinaryTree {

    public static void main(String[] args) {

        //        1
        //     2     3
        //    4  5  6  7

        TreeNode root = new TreeNode(1,
                new TreeNode(2, new TreeNode(4, null, null), new TreeNode(5, null, null)),
                new TreeNode(3, new TreeNode(6, null, null), new TreeNode(7, null, null))
        );

        LinkedListQueue<TreeNode> queue = new LinkedListQueue<>();
        queue.offer(root);
        while (!queue.isEmpty()){
            TreeNode n = queue.poll();
            System.out.println(n);

            if (n.left!=null) {
                queue.offer(n.left);
            }
            if (n.right!=null) {
                queue.offer(n.right);
            }
        }
    }
}
